package org.qloudgen.borg.beans;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.wicket.Page;

public class MenuNode implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String id;
	private String name;
	private String dbParent;
	private String dbClass;
	private MenuNode parent;
	private Class<? extends Page> pageClass;
	private List<MenuNode> children = new ArrayList<MenuNode>();
	
	public MenuNode(){
		
	}
	
    public MenuNode(String id, String name)
    {
        this.id = id;
        this.name = name;
    }

    public MenuNode(MenuNode parent, String id, String name)
    {
        this(id,name);

        this.parent = parent;
        this.parent.children.add(this);
    }
	
	public MenuNode getParent() {
		return parent;
	}
	public void setParent(MenuNode parent) {
		this.parent = parent;
		this.parent.children.add(this);
	}
	
	public List<MenuNode> getChildren() {
		return Collections.unmodifiableList(children);
	}
	
	public void setChildren(List<MenuNode> children) {
		this.children = children;
	}
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}	
	
	 @Override
    public String toString()
    {
        return name;
    }

	public Class<? extends Page> getPageClass() {
		return pageClass;
	}

	public void setPageClass(Class<? extends Page> pageClass) {
		this.pageClass = pageClass;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDbClass() {
		return dbClass;
	}

	public void setDbClass(String dbClass) {
		this.dbClass = dbClass;
	}

	public String getDbParent() {
		return dbParent;
	}

	public void setDbParent(String dbParent) {
		this.dbParent = dbParent;
	}

}
